using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using emp.Model;
using emp.BLL;
using emp.Utility;

public partial class crm_nurturing_NurturingList : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!this.Page.IsPostBack)
        {
            if (Request["state"] != null && Request["state"] != "")
            {
                this.state.Value = Request["state"];
            }
            if (Request["cur_page"] != null && Request["cur_page"] != "")
            {
                this.gvquestlist.PageIndex = int.Parse(Request["cur_page"].ToString());
            }
            inital();
        }
    }
    protected void search_Click(object sender, EventArgs e)
    {
        inital();
    }
    protected void gvquestlist_PageIndexChanging(object sender, GridViewPageEventArgs e)
    {

        GridView theGrid = sender as GridView;
        int newPageIndex = 0;



        if (-2 == e.NewPageIndex)
        {
            TextBox txtNewPageIndex = null;
            GridViewRow pagerRow = theGrid.BottomPagerRow;
            if (null != pagerRow)
            {
                txtNewPageIndex = pagerRow.FindControl("txtNewPageIndex") as TextBox;
            }
            if (null != txtNewPageIndex)
            {
                newPageIndex = int.Parse(txtNewPageIndex.Text) - 1;
            }
        }
        else
        {
            newPageIndex = e.NewPageIndex;
        }

        newPageIndex = newPageIndex < 0 ? 0 : newPageIndex;
        newPageIndex = newPageIndex >= theGrid.PageCount ? theGrid.PageCount - 1 : newPageIndex;
        theGrid.PageIndex = newPageIndex;
        inital();
    }
    private void inital()
    {
        Nurturing nur = new Nurturing();
        string[] parm = new string[4];
        parm[0] = this.state.Value;
        parm[1] = this.dm_name.Text;
        parm[2] = this.begin_time.Text;
        parm[3] = this.end_time.Text;
        IList data = nur.getNurturingList(parm);
        this.gvquestlist.DataSource = data;
        this.gvquestlist.DataBind();
        PageUtil.setPageCount(gvquestlist, data);
    }
}
